home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Aplikacje_64-bitowe / Mixxx / mixxx-1.9.0-win64.exe / midi / Mixman DM2 (OS X).js < prev    next >
Encoding:
Text File  |  2010-12-02  |  7.1 KB  |  226 lines

  1.  
  2. function DM2() {}
  3.  
  4. DM2.pitch2deck =   {  "0" : 1, // Left  Wheel
  5.                       "1" : 2  // Right Wheel
  6. };
  7.  
  8. DM2.button2deck =  {  "1" : 1,
  9.                       "1" : 2,
  10.                      "30" : 1, // Left  filterHighKill
  11.                      "29" : 1, // Left  filterMidKill
  12.                      "28" : 1, // Left  filterlowKill
  13.                      "16" : 2, // Right filterHighKill
  14.                      "17" : 2, // Right filterMidKill
  15.                      "18" : 2, // Right filterLowKill
  16.                      "23" : 2, // Right flanger
  17.                      "31" : 1, // Left  flanger
  18.                      "19" : 2, // Right cue_default
  19.                      "27" : 1, // Left  cue_default
  20.                      "22" : 2, // Right rate_perm_up_small
  21.                      "24" : 1, // Left  rate_perm_up_small
  22.                      "20" : 2, // Right rate_perm_down_small
  23.                      "26" : 1  // Left  rate_perm_down_small
  24. };
  25.  
  26. DM2.button2mixxx = { "30" : "filterHighKill", // Left
  27.                      "29" : "filterMidKill",  // Left
  28.                      "28" : "filterLowKill",  // Left
  29.                      "16" : "filterHighKill", // Right
  30.                      "17" : "filterMidKill",  // Right
  31.                      "18" : "filterLowKill",  // Right
  32.                      "23" : "flanger",        // Right
  33.                      "31" : "flanger",        // Left
  34.                      "19" : "cue_default",    // Right
  35.                      "27" : "cue_default",    // Left
  36.                      "22" : "rate_perm_up_small",    // Right
  37.                      "24" : "rate_perm_up_small",    // Left
  38.                      "20" : "rate_perm_down_small",    // Right
  39.                      "26" : "rate_perm_down_small"     // Left
  40. };
  41.  
  42. DM2.cc2deck =      {  "3" : 1, // Left  filterHighKill
  43.                       "4" : 2, // Right filterHighKill
  44.                       "5" : 1, // Left  filterMidKill
  45.                       "6" : 2, // Right filterMidKill
  46.                       "7" : 1, // Left  filterLowKill
  47.                       "8" : 2, // Right filterLowKill
  48.                       "9" : 1, // Left  gain
  49.                      "10" : 2, // Right gain
  50.                      "11" : 1, // Left  volume
  51.                      "12" : 2, // Right volume
  52.                      "13" : 1, // left  rate
  53.                      "14" : 2  // Right rate
  54. };
  55.  
  56. DM2.cc2mixxx =    {   "3" : "filterHigh", // Left
  57.                       "4" : "filterHigh", // Right
  58.                       "5" : "filterMid",  // Left
  59.                       "6" : "filterMid",  // Right
  60.                       "7" : "filterLow",  // Left
  61.                       "8" : "filterLow",  // Right
  62.                       "9" : "pregain",    // Left
  63.                      "10" : "pregain",    // Right
  64.                      "11" : "volume",     // Left
  65.                      "12" : "volume",     // Right
  66.                      "13" : "rate",       // left
  67.                      "14" : "rate"        // Right
  68. };
  69.  
  70.  
  71. DM2.acc = 0;
  72. DM2.lastacc = 0;
  73. DM2.playlist_channel = -1;
  74. DM2.filter_active = 0;
  75.  
  76. DM2.init = function (id) {   // called when the MIDI device is opened & set up
  77.     print ("======DM2: initialized. " + id );
  78. }
  79.  
  80. DM2.shutdown = function () {   // called when the MIDI device is closed
  81.     print ("======DM2: shutdown...");
  82. }
  83.  
  84. DM2.wheel = function (channel, control, value, status ) {
  85.     // 14bit values
  86.     var newValue = ( value << 7 ) | control;
  87.     if( newValue >= 8192 )
  88.         newValue = newValue - 16384;
  89. //     print( "14bit: " + newValue );
  90.  
  91. //     print( "setting wheel("+channel +"): " + "[Channel" + DM2.pitch2deck[channel] + "]" + " to " + newValue/512.0 );
  92.     engine.setValue( "[Channel" + DM2.pitch2deck[channel] + "]", "jog", newValue/512.0 );
  93.  
  94. //     if( channel == 0 ) {
  95. //         if( engine.getValue("[Channel2]","VuMeter") > 0.6 )
  96. //             print( "*" );
  97. //         else
  98. //             print( "" );
  99. //         print ("playpos: " + engine.getValue("[Channel2]","VuMeter"));
  100. //     }
  101. /*    print( "=====DM2:" );
  102.     print( " - channel: "  + channel  );
  103.     print( " - control: "  + control  );
  104.     print( " - value: "    + value    );
  105.     print( " - status: "   + status   );
  106.     print( "setting jog: " + newValue   );*/
  107. }
  108.  
  109. DM2.playlist = function (channel, control, value, status) {
  110.     // 7bit values
  111.     var newValue=value;
  112.     if( value >= 64 )
  113.         newValue = newValue - 128;
  114.  
  115.     DM2.acc += newValue;
  116.  
  117.     if( DM2.acc > DM2.lastacc + 20 )
  118.     {
  119.         DM2.playlist_channel = channel;
  120.         engine.setValue( "[Playlist]", "SelectNextTrack", 1 );
  121.         DM2.lastacc = DM2.acc;
  122.     }
  123.     else if( DM2.acc < DM2.lastacc - 20 )
  124.     {
  125.         DM2.playlist_channel = channel;
  126.         engine.setValue( "[Playlist]", "SelectPrevTrack", 1 );
  127.         DM2.lastacc = DM2.acc;
  128.     }
  129. }
  130.  
  131. DM2.middle = function (channel, control, value, status) {
  132.     if( DM2.playlist_channel != -1 )
  133.     {
  134.         engine.setValue( "[Playlist]", "LoadSelectedIntoFirstStopped", 1 );
  135. //         engine.setValue( "[Channel" + DM2.playlist_channel + "]", "LoadSelectedTrack", 1 );
  136.         DM2.playlist_channel = -1;
  137.     }
  138. }
  139.  
  140. DM2.filter = function (channel, control, value, status) {
  141.     var deck = DM2.cc2deck[control];
  142.     // 7bit values
  143.     if( value >= 64 )
  144.         value = value - 128;
  145.  
  146.     var f = engine.getValue( "[Channel" + deck + "]", DM2.cc2mixxx[control] );
  147.     f += value / 256;
  148.     if( f > 4.0 )
  149.         f = 4.0;
  150.     else if( f < 0.0 )
  151.         f = 0.0;
  152.  
  153. //     print( "settiing [Channel" + deck + "] " + DM2.cc2mixxx[control] + " to " + f );
  154.     engine.setValue( "[Channel" + deck + "]", DM2.cc2mixxx[control], f );
  155.     DM2.filter_active = 1;
  156. }
  157.  
  158. DM2.volume = function (channel, control, value, status) {
  159.     var deck = DM2.cc2deck[control];
  160.     // 7bit values
  161.     if( value >= 64 )
  162.         value = value - 128;
  163.  
  164.     var f = engine.getValue( "[Channel" + deck + "]", DM2.cc2mixxx[control] );
  165.     f += value / 512;
  166.     if( f > 1.0 )
  167.         f = 1.0;
  168.     else if( f < 0.0 )
  169.         f = 0.0;
  170.  
  171.     engine.setValue( "[Channel" + deck + "]", DM2.cc2mixxx[control], f );
  172.     DM2.filter_active = 1;
  173. }
  174.  
  175. DM2.rate = function (channel, control, value, status) {
  176.     var deck = DM2.cc2deck[control];
  177.     // 7bit values
  178.     if( value >= 64 )
  179.         value = value - 128;
  180.  
  181.     var f = engine.getValue( "[Channel" + deck + "]", DM2.cc2mixxx[control] );
  182.     f += value / 8192;
  183.     if( f > 1.0 )
  184.         f = 1.0;
  185.     else if( f < -1.0 )
  186.         f = -1.0;
  187.  
  188.     engine.setValue( "[Channel" + deck + "]", DM2.cc2mixxx[control], f );
  189.     DM2.filter_active = 1;
  190. }
  191.  
  192. DM2.filterKill = function( channel, control, value, status )
  193. {
  194.     print( "control "+control );
  195.     if( DM2.filter_active )
  196.         DM2.filter_active = 0;
  197.     else
  198.     {
  199.         print( "setting: " + DM2.button2mixxx[control] + " = " + ( ~ engine.getValue( "[Channel" + DM2.button2deck[control] + "]",
  200.                 DM2.button2mixxx[control] ) & 1 ) );
  201.         engine.setValue( "[Channel" + DM2.button2deck[control] + "]",
  202.             DM2.button2mixxx[control],
  203.             ( ~ engine.getValue( "[Channel" + DM2.button2deck[control] + "]",
  204.                 DM2.button2mixxx[control] ) & 1 ) );
  205.     }
  206. }
  207.  
  208.  
  209. // TODO: does not work
  210. DM2.trigger = function( channel, control, value, status )
  211. {
  212.     print( "trigger "+control );
  213.     if( DM2.filter_active )
  214.         DM2.filter_active = 0;
  215.     else
  216.     {
  217.         var f = engine.getValue( "[Channel" + DM2.button2deck[control] + "]", DM2.button2mixxx[control] );
  218.         engine.setValue( "[Channel" + DM2.button2deck[control] + "]",
  219.             DM2.button2mixxx[control], 1 );
  220.         var i;
  221.         for( i = 0; i < 10000; i++ ) ;
  222.         engine.setValue( "[Channel" + DM2.button2deck[control] + "]",
  223.             DM2.button2mixxx[control], 0 );
  224.     }
  225. }
  226.